[rocprof-compute] Adding Triton backend to marker injection#6901
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends rocprofiler-compute’s ROCTX marker injection and analysis pipeline to support a Triton backend alongside the existing PyTorch backend, adding new CLI flags, backend-aware operator filtering/listing, and shared Python-tier ROCTX initialization.
Changes:
- Add Triton tracing/profile CLI support (
--triton-trace) and analysis CLI support (--list-triton-operators,--triton-operator) with updated docs. - Implement and test a hardened Triton ROCTX injection backend that wraps Triton kernel launch entry points and attributes markers to a
Backendcolumn. - Generalize analyze-side operator selection/listing to be backend-aware (torch vs triton), including per-backend matched trace storage.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/rocprofiler-compute/tests/test_utils.py | Adds tests for backend-aware operator pattern parsing and backend filtering in analysis CLI. |
| projects/rocprofiler-compute/tests/test_profiler_base.py | Adds tests validating CLI framework selection and subprocess env var construction. |
| projects/rocprofiler-compute/tests/test_inject_roctx_module.py | Adds Triton backend unit tests (wrapping behavior, reentrancy guard, python-tier handling, kernel name extraction). |
| projects/rocprofiler-compute/src/utils/tty.py | Generalizes operator listing output to support a configurable framework label (PyTorch/Triton). |
| projects/rocprofiler-compute/src/utils/schema.py | Extends Workload to store matched API-trace rows per backend. |
| projects/rocprofiler-compute/src/utils/inject_roctx/_core.py | Introduces shared Python-tier ROCTX initialization (ensure_python_tier) and candidate path tracking. |
| projects/rocprofiler-compute/src/utils/inject_roctx/_backends/_triton.py | Adds/extends Triton backend wrapping logic for kernel launches and framework-root registration. |
| projects/rocprofiler-compute/src/utils/inject_roctx/_backends/_torch.py | Switches torch backend to use shared Python-tier initialization and shared candidate-path reporting. |
| projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_base.py | Adds Triton framework selection mapping for ROCTX injection env var. |
| projects/rocprofiler-compute/src/rocprof_compute_analyze/analysis_cli.py | Refactors operator list/filter flow to be backend-aware and adds backend filtering on consolidated API traces. |
| projects/rocprofiler-compute/src/argparser.py | Adds CLI flags for Triton tracing and Triton operator listing/filtering. |
| projects/rocprofiler-compute/docs/how-to/profile/mode.rst | Documents Triton trace usage, requirements, and relationship to ROCTX frameworks env var. |
| projects/rocprofiler-compute/docs/how-to/analyze/cli.rst | Documents Triton operator analysis and its CLI usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
baf2456 to
de095d3
Compare
f2d20b8 to
50aabb3
Compare
c4ac4c9 to
46559c0
Compare
61a6658 to
81ee094
Compare
657626d to
7007129
Compare
a88ff64 to
6a8df5c
Compare
bff659e to
b0b3164
Compare
b72859d to
ab4f20e
Compare
47add6b to
41d52a1
Compare
Co-authored-by: Pratik Basyal <pratik.basyal@amd.com>
Co-authored-by: cfallows-amd <Carrie.Fallows@amd.com>
Co-authored-by: cfallows-amd <Carrie.Fallows@amd.com>
066804e to
491b779
Compare
xuchen-amd
left a comment
There was a problem hiding this comment.
thanks for addressing my comments, I would appreciate another reviewer feedback (a third one in addition to Carrie and myself).
vedithal-amd
left a comment
There was a problem hiding this comment.
will do a quick review by EOD here
vedithal-amd
left a comment
There was a problem hiding this comment.
A few maintenance-cost notes on the docs plus a coverage-gap flag on the Triton path. See inline.
vedithal-amd
left a comment
There was a problem hiding this comment.
One follow-up note on package naming (see inline).
- C++ build_marker_string: exact reserve() for percent-encoding, extract encode_marker_segment + shared escape constants reused by the round-trip test - analysis_base: collapse per-backend trace-validation into one loop - rename KNOWN_BACKENDS -> KNOWN_ML_API_BACKENDS - rename _BACKEND_CLI -> _ML_API_ANALYSIS_CLI_OPTIONS - utils_analysis: inline decode_marker_name in build_call_trees - test_utils: drop redundant function-local pandas imports Co-Authored-By: Claude <noreply@anthropic.com>
vedithal-amd
left a comment
There was a problem hiding this comment.
LGTM
Pushed one commit (60e1e65) with review nits, all mechanical, no behavior change:
- C++
build_marker_string: exactreserve()accounting for percent-encoding; extractedencode_marker_segment+ shared escape constants, reused by the round-trip test so the escape table has one definition. analysis_base: collapsed the duplicated per-backend trace-validation into a single loop over the backend list.- Renamed
KNOWN_BACKENDS->KNOWN_ML_API_BACKENDSand_BACKEND_CLI->_ML_API_ANALYSIS_CLI_OPTIONS. utils_analysis: inlineddecode_marker_nameinbuild_call_trees.test_utils: dropped redundant function-localpandasimports.
Follow-ups left as separate notes (not blocking): rename _backends -> backends, and ML-API coverage test.
9ee8251 to
ccd5d6d
Compare
Resolved all the issues raised by Pratik. But dismissing since he is OOO this week and can't approve before the end of this sprint. For the sake of unblocking
Motivation
This PR enables operator tracing for Triton workloads.
Technical Details
--triton-trace(and--ml-api-tracefor all backends) for profiling and--list-triton-operators/--triton-operatorfor analysis, driven by a shared backend registry.tests/workloads/triton_trace/MI300Aandtests/workloads/ml_api_trace/MI300A, so the per-backend analyze tests run CPU-only in CI.JIRA ID
AIPROFCOMP-635
Test Plan
Triton backend unit tests (wrapping, reentrancy dedup, kernel-name, percent-encode round trip)
ctest -R test_inject_roctx_packageFramework selection (flag -> backend, env var)
ctest -R test_profiler_baseAnalyze: per-backend operator filtering
ctest -R test_analyze_workloadsUtils: operator pattern parsing
ctest -R test_utilsC++ gtests: percent-encode + round-trip decode
ctest -R test-roctx-recordfnEnd-to-end Triton profile + analyze (requires GPU + Triton)
ctest -R test_profile_triton_traceTest Result
Tests Pass
Submission Checklist